﻿using myBackupClient.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace myBackupClient
{
    public partial class frmSetting : Form
    {
        public frmSetting()
        {
            InitializeComponent();
        }
        private void frmSetting_Load(object sender, EventArgs e)
        {
            textBox_port.Text = BackupConfig.Instance.IpPort;
            textBox_backupSaveRootPath.Text = BackupConfig.Instance.BackupSaveRootPath;
            foreach (var item in BackupConfig.Instance.Paths)
            {
                dataGridView_paths.Rows.Add(item.Value.Path);
            }
        }

        private void button_save_Click(object sender, EventArgs e)
        {
            BackupConfig.Instance.IpPort = textBox_port.Text;
            BackupConfig.Instance.BackupSaveRootPath = textBox_backupSaveRootPath.Text;
            BackupConfig.Instance.Save();
        }

        private void button_browser_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                textBox_backupSaveRootPath.Text=dialog.SelectedPath;
            }
        }
    }
}
